package com.easemob.chat;

import com.easemob.EMCallBack;
import com.easemob.util.EMLog;
import java.io.File;
import org.jivesoftware.smack.packet.Packet;

class EMMessageUtils
{
  private static final String TAG = EMMessageUtils.class.getSimpleName();

  static int checkMessageError(EMMessage paramEMMessage)
  {
    String str;
    Object localObject;
    if (paramEMMessage.getType() == EMMessage.Type.FILE)
    {
      str = ((NormalFileMessageBody)paramEMMessage.getBody()).localUrl;
      localObject = new File(str);
      if (!((File)localObject).exists())
      {
        EMLog.e(TAG, "file doesn't exists:" + str);
        return -1012;
      }
      if (((File)localObject).length() == 0L)
      {
        EMLog.e(TAG, "file size is 0:" + str);
        return -1011;
      }
    }
    else if (paramEMMessage.getType() == EMMessage.Type.IMAGE)
    {
      str = ((ImageMessageBody)paramEMMessage.getBody()).localUrl;
      localObject = new File(str);
      if (!((File)localObject).exists())
      {
        EMLog.e(TAG, "image doesn't exists:" + str);
        return -1012;
      }
      if (((File)localObject).length() == 0L)
      {
        EMLog.e(TAG, "image size is 0:" + str);
        return -1011;
      }
    }
    else if (paramEMMessage.getType() == EMMessage.Type.VOICE)
    {
      str = ((VoiceMessageBody)paramEMMessage.getBody()).localUrl;
      localObject = new File(str);
      if (!((File)localObject).exists())
      {
        EMLog.e(TAG, "voice file doesn't exists:" + str);
        return -1012;
      }
      if (((File)localObject).length() == 0L)
      {
        EMLog.e(TAG, "voice file size is 0:" + str);
        return -1011;
      }
    }
    else if (paramEMMessage.getType() == EMMessage.Type.VIDEO)
    {
      str = ((VideoMessageBody)paramEMMessage.getBody()).localUrl;
      localObject = ((VideoMessageBody)paramEMMessage.getBody()).localThumb;
      File localFile1 = new File(str);
      File localFile2 = new File((String)localObject);
      if (!localFile1.exists())
      {
        EMLog.e(TAG, "video file doesn't exists:" + str);
        return -1012;
      }
      if (localFile1.length() == 0L)
      {
        EMLog.e(TAG, "video file size is 0:" + str);
        return -1011;
      }
      if (!localFile2.exists())
      {
        EMLog.e(TAG, "video thumb image doesn't exists:" + (String)localObject);
        return -1012;
      }
      if (localFile2.length() == 0L)
      {
        EMLog.e(TAG, "video thum image size is 0:" + (String)localObject);
        return -1011;
      }
    }
    return 0;
  }

  static void asyncCallback(EMCallBack paramEMCallBack, final int paramInt, final String paramString)
  {
    if (paramEMCallBack == null)
      return;
    new Thread()
    {
      public void run()
      {
        EMMessageUtils.this.onError(paramInt, paramString);
      }
    }
    .start();
  }

  static String getUniqueMessageId()
  {
    String str = Long.toHexString(System.currentTimeMillis());
    str = str.substring(6);
    return Packet.nextID() + "-" + str;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     com.easemob.chat.EMMessageUtils
 * JD-Core Version:    0.6.1
 */